//
//  ZSY_TravelSevenTableViewCell.m
//  ZSY_BreadTrip
//
//  Created by 张诗宇 on 15/12/30.
//  Copyright © 2015年 张诗宇. All rights reserved.
//

#import "ZSY_TravelSevenTableViewCell.h"

@interface ZSY_TravelSevenTableViewCell ()

@property (nonatomic, retain) ZSY_BaseLabel *title;
@property (nonatomic, retain) ZSY_BaseLabel *sub_title;
@property (nonatomic, retain) ZSY_BaseImageView *cover;

@end

@implementation ZSY_TravelSevenTableViewCell

- (void)dealloc {
    [_title release];
    [_sub_title release];
    [_cover release];
    [super dealloc];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)setSeven:(ZSY_TravelProduct *)seven {
    if (_seven != seven) {
        [_seven release];
        _seven = [seven retain];
    NSURL *coverUrl = [NSURL URLWithString:_seven.cover];
    [self.cover sd_setImageWithURL:coverUrl placeholderImage:nil];
    
    self.title.text = _seven.title;
    self.title.textAlignment = NSTextAlignmentCenter;
    self.title.font = [UIFont systemFontOfSize:21];
    self.title.font = [UIFont boldSystemFontOfSize:22];
    
    NSString *string = [NSString stringWithFormat:@"「 %@ 」", self.seven.sub_title];
    self.sub_title.text = string;
//    [self.sub_title sizeToFit];
    self.sub_title.font = [UIFont systemFontOfSize:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               14];
    self.sub_title.textAlignment = NSTextAlignmentCenter;
    }
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubview];
    }
    return self;
}

- (void)createSubview {
//    self.contentView.backgroundColor = [UIColor colorWithRed:248 / 255.0 green:243 / 255.0 blue:233 / 255.0 alpha:1];

    /**
     背景图片
     
     - returns:
     */
    self.cover = [[ZSY_BaseImageView alloc] initWithFrame:CGRectMake(10, 10, WIDTH - 20, 200)];
//    self.cover.backgroundColor = [UIColor lightGrayColor];
    
    self.cover.layer.cornerRadius = 5;
    self.cover.layer.masksToBounds = YES;
    self.cover.layer.borderWidth = 1;
    self.cover.layer.borderColor = [UIColor lightGrayColor].CGColor;

    [self.contentView addSubview:_cover];
    /**
     滤镜
     
     - returns:
     */
    ZSY_BaseImageView *view = [[ZSY_BaseImageView alloc] initWithFrame:CGRectMake(0, 0, self.cover.frame.size.width, self.cover.frame.size.height)];
    view.layer.cornerRadius = 5;
    view.layer.masksToBounds = YES;
    view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
    [self.cover addSubview:view];
    
    /**
     *  title Label
     */
    self.title = [[ZSY_BaseLabel alloc] initWithFrame:CGRectMake(0, 80, WIDTH - 20, 20)];
//    self.title.backgroundColor = [UIColor blueColor];
    self.title.textColor = [UIColor whiteColor];
    [view addSubview:_title];
    [_title release];
    /**
     *  sub_title Label
     */
    self.sub_title = [[ZSY_BaseLabel alloc] initWithFrame:CGRectMake(0, 110, WIDTH - 20, 20)];
//    self.sub_title.backgroundColor = [UIColor blackColor];
    self.sub_title.textColor = [UIColor whiteColor];
    [view addSubview:_sub_title];
    [_sub_title release];
    
}


@end
